{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['a' '9' '8' '2']\n",
      "67\n",
      "2\n"
     ]
    }
   ],
   "source": [
    "#!/usr/bin/env python\n",
    "# -*- coding:utf-8 -*-\n",
    "\n",
    "import numpy\n",
    "# 创建一维数组格式\n",
    "# numpy.array([元素1,元素2,...,])\n",
    "x = numpy.array([\"a\",\"9\",\"8\",\"2\"])\n",
    "# 创建二维数组格式\n",
    "# numpy.array([[元素1,元素2,...],[元素1,...])\n",
    "y = numpy.array([[3,13,10],[9,2,67],[2,6,11]])\n",
    "print(x)\n",
    "# 排序sort()\n",
    "x.sort()\n",
    "y.sort()\n",
    "# 取最大值和最小值\n",
    "y1 = y.max()\n",
    "y2 = y.min()\n",
    "print(y1)\n",
    "print(y2)\n",
    "# 切片\n",
    "# 数组[起始下标:最终下标+1]\n",
    "x1 = x[1:3] # 1-2\n",
    "x2 = x[:2]\n",
    "x3 = x[1:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "lines_to_next_cell": 0
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0    8\n",
      "1    9\n",
      "2    2\n",
      "3    1\n",
      "dtype: int64\n",
      "one      8\n",
      "two      9\n",
      "three    2\n",
      "four     1\n",
      "dtype: int64\n",
      "========================================\n",
      "   0  1   2  3\n",
      "0  5  6   2  3\n",
      "1  8  4   6  3\n",
      "2  6  4  31  2\n",
      "====================\n",
      "   one  two  three  four\n",
      "0    5    6      2     3\n",
      "1    8    4      6     3\n",
      "2    6    4     31     2\n",
      "--------------------\n",
      "   one  two  three  four\n",
      "0    5    6      2     3\n",
      "1    8    4      6     3\n",
      "2    6    4     31     2\n",
      "--------------------\n",
      "   one  two  three  four\n",
      "0    5    6      2     3\n",
      "1    8    4      6     3\n",
      "--------------------\n",
      "   one  two  three  four\n",
      "0    5    6      2     3\n",
      "1    8    4      6     3\n",
      "2    6    4     31     2\n",
      "==========\n",
      "   one  two  three  four\n",
      "1    8    4      6     3\n",
      "2    6    4     31     2\n",
      "            one       two      three      four\n",
      "count  3.000000  3.000000   3.000000  3.000000\n",
      "mean   6.333333  4.666667  13.000000  2.666667\n",
      "std    1.527525  1.154701  15.716234  0.577350\n",
      "min    5.000000  4.000000   2.000000  2.000000\n",
      "25%    5.500000  4.000000   4.000000  2.500000\n",
      "50%    6.000000  4.000000   6.000000  3.000000\n",
      "75%    7.000000  5.000000  18.500000  3.000000\n",
      "max    8.000000  6.000000  31.000000  3.000000\n",
      "       0  1   2\n",
      "one    5  8   6\n",
      "two    6  4   4\n",
      "three  2  6  31\n",
      "four   3  3   2\n"
     ]
    }
   ],
   "source": [
    "import pandas as pda \n",
    "'''\n",
    "Series # index索引.\n",
    "DataFrame\n",
    "'''\n",
    "a = pda.Series([8,9,2,1])\n",
    "b = pda.Series([8,9,2,1],index=[\"one\",\"two\",\"three\",\"four\"])\n",
    "c = pda.DataFrame([[5,6,2,3],[8,4,6,3],[6,4,31,2]])\n",
    "d = pda.DataFrame([[5,6,2,3],[8,4,6,3],[6,4,31,2]],columns=[\"one\",\"two\",\"three\",\"four\"])\n",
    "\n",
    "print(a)\n",
    "print(b)\n",
    "print('=='*20)\n",
    "print(c)\n",
    "print('=='*10)\n",
    "print(d)\n",
    "print('--'*10)\n",
    "print(d.head()) # 头部数据,默认前五行.\n",
    "print('--'*10) \n",
    "print(d.head(2)) # d.head(行数)\n",
    "print('--'*10)\n",
    "print(d.tail()) # 尾部数据,默认是后五行.\n",
    "print('='*10)\n",
    "print(d.tail(2)) # d.tail(行数)\n",
    "\n",
    "print(d.describe()) \n",
    "'''\n",
    "输出的说明: \n",
    "    count统计的是: 元素个数的信息.\n",
    "    mean统计的是: 平均数.\n",
    "    std: 标准差.\n",
    "    min: 最小值.\n",
    "    25%: 每一列的分位数.\n",
    "    50%: 每一列的分位数.\n",
    "    75%: 每一列的分位数.\n",
    "'''\n",
    "print(d.T) # 转置\n",
    "e = pda.DataFrame({\n",
    "    \"one\":4,\n",
    "    \"two\":[6,2,3],\n",
    "    \"three\":list(str(982))\n",
    "})\n",
    "# print(e)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "jupytext": {
   "formats": "ipynb,py:light"
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
